import 'package:flutter/material.dart';
import 'package:flutter_custom_bottom_tab_bar/tabbar.dart';
import 'package:flutter_custom_bottom_tab_bar/eachtab.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:panda/base/application.dart';
import 'package:panda/jiayouzhan/KefuTalk.dart';
import 'package:panda/login/Welcome.dart';
import 'dart:ui';
import '../base/Constant.dart';
import 'AllOrderPage.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class Order2Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new Order2View();
  }
}

class Order2View extends State<Order2Page> with SingleTickerProviderStateMixin {
  TabController _tabController;
  String badgeNo1;
  var titles = ['申请退款'];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController =
        new TabController(vsync: this, initialIndex: 0, length: titles.length);
    badgeNo1 = '12';
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    final width = size.width;
    return Scaffold(
      appBar: AppBar(
          title: Text(
            '售后服务',
            style: TextStyle(
                color: black,
                fontSize: ScreenUtil.getInstance().setSp(BIG_FONT_SIZE)),
          ),
          elevation: 0.5,
          backgroundColor: white,
          iconTheme: new IconThemeData(color: black_99),
          brightness: Brightness.light,
          actions: <Widget>[
            Container(
              alignment: Alignment.center,
              padding: EdgeInsets.all(5),
              margin: EdgeInsets.only(right: 13, top: 2),
              child: GestureDetector(
                behavior: HitTestBehavior.opaque,
                child: Column(
                  children: <Widget>[
                    Image.asset("images/kf.png",
                        width: ScreenUtil.getInstance().setHeight(35)),
                    Text('客服',
                        style: TextStyle(
                            color: mainColor,
                            fontSize: ScreenUtil.getInstance().setSp(20)))
                  ],
                ),
                onTap: () {
                  if (APPLIC.userInfoMap == null) {
                    Fluttertoast.showToast(
                        msg: "请先登录", gravity: ToastGravity.CENTER);
                    Navigator.of(context)
                        .push(new MaterialPageRoute(builder: (context) {
                      return new WelComePage();
                    }));
                    return;
                  }
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (context) {
                    return KeFuTalkPage(
                        url: "http://kf.0731app.cn/index/index/home?visiter_id=" +
                                            APPLIC.userInfoMap['user_msg']
                                                    ['uid']
                                                .toString() +
                                            "&visiter_name="+ "name"+"&avatar="+ APPLIC.userInfoMap['user_detail']
                                                    ['avatar']
                                                .toString()+"&business_id=1&groupid=4&special=5");
                  }));
                },
              ),
            )
          ],
          bottom: TabContainer(
              // alignment: Alignment.center,
              height: 0,
              color: Colors.white,
              child: Stack(
                overflow: Overflow.clip,
                children: <Widget>[
                  Container(
                    height: 0,
                    child: new TabBar(
                      isScrollable: true,
                      controller: _tabController,
                      indicatorColor: mainColor,
                      labelColor: mainColor,
                      labelPadding: EdgeInsets.all(0),
                      unselectedLabelColor: Colors.black,
                      tabs: <Widget>[
                        EachTab(
                          text: titles[0],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE - 2)),
                        ),
                        // EachTab(
                        //   text: titles[1],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // EachTab(
                        //   text: titles[2],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // EachTab(
                        //   text: titles[3],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // EachTab(
                        //   text: titles[4],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // EachTab(
                        //   text: titles[5],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // new EachTab(
                        //   text: titles[3],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // new EachTab(
                        //   text: titles[4],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        //  EachTab(
                        //   text: titles[5],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // new EachTab(
                        //   text: titles[6],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        //  EachTab(
                        //   text: titles[7],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE - 2)),
                        // ),
                        // new EachTab(
                        //   width: width / 5,
                        //   text: titles[4],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance().setSp(NORMAL_FONT_SIZE)),
                        // ),
                      ],
                    ),
                  ),
                ],
              ))),
      body: TabBarView(controller: _tabController, children: <Widget>[
        // Center(
        //     child: new AllOrderPage(
        //   type: 0,
        // )),
        // Center(
        //     child: AllOrderPage(
        //   type: 2,
        // )),
        // Center(
        //     child: AllOrderPage(
        //   type: 3,
        // )),
        // Center(
        //     child: AllOrderPage(
        //   type: 4,
        // )),
        Center(
            child: AllOrderPage(
          type: 6,
        )),
        //  Center(
        //     child: AllOrderPage(
        //   type: 7,
        // )),
        //  Center(
        //     child: AllOrderPage(
        //   type: 8,
        // )),
        //   Center(
        //     child: AllOrderPage(
        //   type: 10,
        // )),
        //  Center(
        //     child: AllOrderPage(
        //   type: 11,
        // )),
        //  Center(
        //     child: AllOrderPage(
        //   type: 12,
        // )),
        // Center(
        //     child: AllOrder2Page(
        //   type: 5,
        // )),
        // Center(child: AllOrderPage(type: 9,)),
      ]),
    );
  }
}
